use std::env;
use std::process::exit;

fn main() {
    let args: Vec<String> = env::args().collect();

    // 参数检查
    if args.len() != 2 {
        eprintln!("usage: {} [positive-integer]", args[0]);
        exit(1);
    }

    // 尝试将参数转换为整数
    let num: i32 = match args[1].parse() {
        Ok(n) if n > 0 => n,
        _ => {
            eprintln!("usage: {} [positive-integer]", args[0]);
            exit(1);
        }
    };

    // 计算阶乘
    let mut res = 1;
    for i in 1..=num {
        res *= i;
    }

    println!("{}", res);
}
